package com.sccba.web.controller.yjcz;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.sccba.common.annotation.Log;
import com.sccba.common.core.controller.BaseController;
import com.sccba.common.core.domain.AjaxResult;
import com.sccba.common.core.domain.entity.SysUser;
import com.sccba.common.core.page.TableDataInfo;
import com.sccba.common.enums.BusinessType;
import com.sccba.common.utils.poi.ExcelUtil;
import com.sccba.system.service.ISysUserService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.sccba.emtbusiness.domain.YjczDutyPerson;
import com.sccba.emtbusiness.service.IYjczDutyPersonService;

/**
 * 发版值班人员Controller
 * 
 * @author lichh
 * @date 2024-04-28
 */
@RestController
@RequestMapping("/yjcz/dutyPerson")
public class YjczDutyPersonController extends BaseController
{
    @Autowired
    private IYjczDutyPersonService yjczDutyPersonService;

    @Autowired
    private ISysUserService sysUserService;

    /**
     * 查询发版值班人员列表
     */
    @PreAuthorize("@ss.hasPermi('yjcz:dutyPerson:list')")
    @GetMapping("/list")
    public TableDataInfo list(YjczDutyPerson yjczDutyPerson)
    {
        startPage();
        List<YjczDutyPerson> list = yjczDutyPersonService.selectYjczDutyPersonList(yjczDutyPerson);
        return getDataTable(list);
    }

    /**
     * 导出发版值班人员列表
     */
    @PreAuthorize("@ss.hasPermi('yjcz:dutyPerson:export')")
    @Log(title = "发版值班人员", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, YjczDutyPerson yjczDutyPerson)
    {
        List<YjczDutyPerson> list = yjczDutyPersonService.selectYjczDutyPersonList(yjczDutyPerson);
        ExcelUtil<YjczDutyPerson> util = new ExcelUtil<YjczDutyPerson>(YjczDutyPerson.class);
        util.exportExcel(response, list, "发版值班人员数据");
    }

    /**
     * 获取发版值班人员详细信息
     */
    @PreAuthorize("@ss.hasPermi('yjcz:dutyPerson:query')")
    @GetMapping(value = "/{pkId}")
    public AjaxResult getInfo(@PathVariable("pkId") Long pkId)
    {
        return success(yjczDutyPersonService.selectYjczDutyPersonByPkId(pkId));
    }

    /**
     * 新增发版值班人员
     */
    @PreAuthorize("@ss.hasPermi('yjcz:dutyPerson:add')")
    @Log(title = "发版值班人员", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YjczDutyPerson yjczDutyPerson)
    {
        return toAjax(yjczDutyPersonService.insertYjczDutyPerson(yjczDutyPerson));
    }

    /**
     * 修改发版值班人员
     */
    @PreAuthorize("@ss.hasPermi('yjcz:dutyPerson:edit')")
    @Log(title = "发版值班人员", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YjczDutyPerson yjczDutyPerson)
    {
        return toAjax(yjczDutyPersonService.updateYjczDutyPerson(yjczDutyPerson));
    }

    /**
     * 删除发版值班人员
     */
    @PreAuthorize("@ss.hasPermi('yjcz:dutyPerson:remove')")
    @Log(title = "发版值班人员", businessType = BusinessType.DELETE)
	@DeleteMapping("/{pkIds}")
    public AjaxResult remove(@PathVariable Long[] pkIds)
    {
        return toAjax(yjczDutyPersonService.deleteYjczDutyPersonByPkIds(pkIds));
    }


    @GetMapping("/userList")
    public AjaxResult list(SysUser sysUser)
    {
        List<SysUser> userList = sysUserService.selectUserList(sysUser);
        return success(userList);
    }

    @GetMapping("/getListByFbId/{fbId}")
    public AjaxResult getListByFbId (@PathVariable("fbId") Long fbId) {
        return success(yjczDutyPersonService.getListByFbId(fbId));
    }

    @PostMapping("/savePersonList")
    public AjaxResult savePersonList (@RequestBody List<YjczDutyPerson> dutyPersonList) {
        yjczDutyPersonService.saveDutyPersonList(dutyPersonList);
        return success();
    }
}
